#include "GameMario.h"
#include "FWContent.h"
#include "FWGraphic.h"
#include "FWTexture.h"
#include "ShareComponent.h"
#include "LocalComponent.h"
#include "FWKeyboard.h"
#include "Mario.h"
#include"FWCamera.h"
#include"FWMap.h"

GameMario::GameMario(HINSTANCE hinst,char* name,int w, int h) : FWGame(hinst,name,w,h)
{
	//glGraphic = new FWGraphic(this);
	glContent = new FWContent(this);

}


GameMario::~GameMario(void)
{
}

void GameMario::Load()
{	
	target=D3DXVECTOR2(0,0);
	keyboard = new FWKeyboard(this);
	brush = new FWGraphic(this);
	glGraphic = brush;
	FWContent* a = new FWContent(this);
	FWTexture* _texture= a->LoadTexture("KetQua1.png");
	camera = new FWCamera(0,7168,480);

	map = new FWMap();
	map->Init("Map.txt",_texture);
	img = a->LoadTexture("a.png");
	mario = new Mario();
	mario->Load(a);
}

void GameMario::Update()
{
	mario->update();
	keyboard->getState();
	if (keyboard->isKeyDown(DIK_LEFT))
		mario->goLeft();
	if (keyboard->isKeyDown(DIK_RIGHT))
		mario->goRight();
	target.x+=1;
	//target.y+=5;
	camera->update(target);
}

void GameMario::Render()
{	
	brush->Begin(camera->getTransformedMatrix());
	map->Render();

	mario->render();
	brush->End();
}
